﻿@{
    ViewBag.Title = "新增企业资质信息";
    Layout = Url.Content("~/Views/Shared/_Layout.cshtml");
}


<!--总容器开始-->
<div class="page-header">
    <h1>
        @ViewBag.Title
        <small></small>
    </h1>
</div>
<div id="PAGE_MODEL" class="container">
    <h3 style="border-bottom:1px solid #999; padding:.3em;">
        <i class="fa fa-info-circle fa-fw"></i>
        企业资质信息
        <small v-show="VmQualification.Qid!=''&&VmQualification.Qid!=null "><font color="red"><b>先上传附件，再修改信息</b></font></small>
    </h3>
    <div class="row">
        <div class="col-md-12 form-group">
            <div class="input-group">
                <span class="input-group-addon">项目类型</span>
                <input type="text" class="form-control" placeholder="输入项目类型/名称"
                       v-model="VmQualification.Type">
                <span class="input-group-addon"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></span>
            </div>
        </div>
        <div class="col-md-12 form-group">
            <div class="input-group">
                <span class="input-group-addon">项目内容</span>
                <textarea class="form-control" placeholder="输入项目内容"
                          rows="3"
                          v-model="VmQualification.Content"></textarea>
                <span class="input-group-addon"><span class="glyphicon glyphicon-exclamation-sign text-danger" aria-hidden="true"></span></span>
            </div>
        </div>
        <div class="col-md-12 form-group">
            <div class="input-group">
                <span class="input-group-addon">备注说明</span>
                <textarea class="form-control" placeholder="输入备注说明"
                          rows="3"
                          v-model="VmQualification.Remark"></textarea>
            </div>
        </div>
        <!-- 上传附件开始 -->
        <div class="col-md-12 form-group" v-show="VmQualification.Qid!=''&&VmQualification.Qid!=null ">
        <form id="UpAttachment" method="post"
              target="_self" enctype="multipart/form-data">
            @Html.AntiForgeryToken()
            <label>附件上传：</label>

            <input type="file" name="upfile" />

           <input type="hidden" name="recordid" value="@ViewBag.Id"/>

            <input type="hidden" name="typename" value="企业资质附件" />

            <label>
                <button type="button" class="btn"
                        v-on:click="uploadAttachment()">
                    <i class="fa fa-upload"></i>
                    上传
                </button>
            </label>
        </form>


        <div>
            <ul class="list-unstyled" v-cloak>
                <li v-for="attachment in VmQualification.VmAttachments" style="padding-bottom:.3em;">
                    <b>
                        {{attachment.FileName}}
                    </b>
                    <a href="#" v-on:click="DeleteAttachment(attachment.AId)">
                        <i class="fa fa-trash"></i>
                        删除
                    </a>
                </li>
            </ul>
        </div>
    </div>
        <!-- 上传附件结束 -->
        
        <!-- 关联明细显示开始 -->
        <h3 style="border-bottom:1px solid #999; padding:.3em;">
            <i class="fa fa-comment-o fa-fw"></i>
            关联资质明细
            <button class="btn btn-small btn-success"
                    v-on:click="showmodalForSelectQualificationDetails()">
                <i class="fa fa-search"></i>
                选择
            </button>
            <small>请选择与之对应的资质明细</small>
        </h3>
        <div class="row">
            <div class="col-md-12">
                <table class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th class="bg-primary text-center text-nowrap" style="width:1%">序号</th>
                            <th class="bg-primary text-center">资质要求</th>
                            <th class="bg-primary text-center">业务范围</th>
                            <th class="bg-primary text-center">备注</th>
                            <th class="bg-primary text-center text-nowrap" style="width:1%">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(e,index) in VmQualification.VmQualificationDetails">
                            <td class="text-center">{{index+1}}</td>
                            <td>{{e.Details_Require}}</td>
                            <td>{{e.Details_Range}}</td>
                            <td>{{e.Details_Remark}}</td>
                            <td>
                                <a href="#" v-on:click.prevent="deleteQualificationDetails(e)">删除</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 关联明细显示结束 -->

    </div>
    <!-- 提交按钮开始 -->
    <div class="row">
        <div class="col-md-12 text-center">
            <button type="button" class="btn btn-success" v-show="VmQualification.Qid!=''&&VmQualification.Qid!=null " v-on:click="UpdateQualification()">修改并提交</button>
            <button type="button" class="btn btn-primary" v-show="VmQualification.Qid ==''||VmQualification.Qid==null" v-on:click="addQualification()">保存并提交</button>
            <button type="button" class="btn btn-success" v-on:click="window.history.go(-1);">返回前页</button>
        </div>
    </div>
    <!-- 提交按钮结束 -->

    <!-- 关联明细模态框开始 -->
    <div id="FormSelectVmQualificationDetails" class="modal" data-backdrop="static">
        <!--对话框-->
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <!--对话框头-->
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">资质明细查询</h4>
                </div>
                <!--对话框体-->
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <form id="frmXMYZ" class="form-inline" onsubmit="vm.searchQualificationDetails(); return false;">
                                <div class="form-group">
                                    <label for="FormSelectDetails_Require">资质要求：</label>
                                    <input v-model="keyword" type="text" class="form-control"/>
                                    <button type="submit" class="btn btn-primary">
                                        <i class="fa fa-search"></i>
                                        查询
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-bordered table-hover table-responsive" style="margin-top:.5em;">
                        <thead>
                            <tr>
                                <th class="bg-primary text-nowrap text-center" style="width:1%;">序号</th>
                                <th class="bg-primary text-center">资质要求</th>
                                <th class="bg-primary text-center">资质范围</th>
                                <th class="bg-primary text-nowrap text-center" style="width:1%;">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="(e,index) in VmQualificationDetails_BX">
                                <td class="text-center">{{index+1}}</td>
                                <td>{{e.Details_Require}}</td>
                                <td>{{e.Details_Range}}</td>
                                <td>
                                    <a href="#" v-on:click.prevent="selectQualificationDetails(e)">选择</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <!--对话框脚-->
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        <i class="fa fa-close"></i>
                        关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!-- 关联明细模态框结束 -->

</div>
<!--总容器结束-->
@section Script{

    <script src='@Url.Content("~/Scripts/jquery.form.js")' type="text/javascript"></script>

    <script src='@Url.Content("~/Scripts/Qualification/Qualification.js")' type="text/javascript"></script>

    <script type="text/javascript">
        //链接地址定义
        var URLs = {
            URL_UPLOAD_FILES: '@Url.Action("UploadAjax", "Qualification")'                                             //上传附件

            , URL_ADD_QUALIFICATION: '@Url.Action("AddQualificaton", "Qualification")'                                 //添加信息

            , URL_DELETE_QUALIFICATION: '@Url.Action("deleteQualificationData", "Qualification")'                      //删除信息

            , URL_GET_QUALIFICATIONLIST: '@Url.Action("GetQualificationList", "Qualification")'                        //获取列表

            , URL_GET_ONEQUALIFICATION: '@Url.Action("GetOneQualification", "Qualification")'                          //获取一条要编辑的数据

            , URL_UPDATE_QUALIFICATION: '@Url.Action("updateQualification", "Qualification")'                          //修改记录

            //, GET_ATTACHMENTS: '@Url.Action("AttachmentList", "Qualification")'                                        //获取记录ID的附件列表

            , DELETE_ATTACHMENT: '@Url.Action("deleteAttachment", "Qualification")'                                       //删除关联的附件

            , URL_GET_VMQUALIFICATIONDETAILS: '@Url.Action("QualificationDetailList", "Qualification")'                //获取明细列表
        }

        $(function () {
            vm.VmQualification.Qid = "@Request["Qid"]";

            if (vm.VmQualification.Qid != null && vm.VmQualification.Qid != "") {

                vm.getDataFromListToUpdate(vm.VmQualification.Qid);
                
            }
            //vm.GetAttachmentFiles(vm.VmQualification.Qid);
        });
    </script>
}